﻿@model UserMemo
@{
    ViewBag.Title = "备忘录与检查单";
    ViewBag.Back = "/Home/MemoList";
}
@*<div data-role="navbar">
    <ul>
        <li>@Html.ActionLink("我的大事记", "MemoList")</li>
        <li>@Html.ActionLink("检查单", "MemoEditJcd")</li>
        <li>@Html.ActionLink("备忘录", "MemoEdit", null, new { @class = "ui-btn-active site-nav-active ui-shadow" })</li>
    </ul>
</div>*@

@using (Html.BeginForm(null, null, new { IsView = true }, FormMethod.Post, new { enctype = "multipart/form-data" }))
{
    var rds = SiteUser.UserAllRecupers.Where(v => v.GuoQi == false).SelectMany(v => v.QizSubjectObjForDoctors).OrderByDescending(v => v.TimeMark);

    var items = rds.Select(v => new { RecuperID = v.RecuperID, Title = v.Doctor.UserName }).Distinct().ToList();
    //var items = SiteUser.UserAllRecupers.Where(v => v.GuoQi == false).Select(v => new { RecuperID = v.RecuperID, Title = (v.Hospital.HospCode + v.BingQu.Title + v.Department.DepName + v.Doctor.UserName + " " + v.EnHospDay.ToString("yyyy年M月")) }).ToList();
    items.Add(new { RecuperID = "", Title = "[私人备忘录]" });

    var Selects = new SelectList(items, "RecuperID", "Title", Model.RecuperID);
    
    @Html.ValidationSummary(true)
    <fieldset class="edit-fieldset">
        @Html.HiddenFor(model => model.ID)
        @Html.HiddenFor(model => model.CreateTime)
        @Html.HiddenFor(model => model.UserID)
        <div id="memo-editor">
            @Html.EditorFor(model => model.Title, "TxtField")
            @Html.EditorFor(model => model.Timemark, "TxtField")
            @Html.EditorFor(model => model.RecuperID, "SelField", new { Selects =Selects })
            @Html.EditorFor(model => model.MemoText, "LongTxtField")

            <div class="editor-label">检查单照片附件</div>
            <div class="editor-field">
                @Html.Hidden("memopicfile" + ".keep", Model.MemoPic)
                <input name="memopicfile" type="file" onchange="fileInputCheck(this,0.8);" />

                @if (!string.IsNullOrEmpty(Model.MemoPic))
                {
                    var exts = new string[] { ".png", ".jpg", ".jpeg", ".gif" };
                    var ext = System.IO.Path.GetExtension(Model.MemoPic).ToLower();

                    if (exts.Contains(ext))
                    {
                    <a class="imagefield-view" target="_blank" href="@(Url.Action("Img", "Home", new { ID = Model.MemoPic, _newpage = "true" }))">
                        <img alt="照片" src="@(Url.Action("Img", "Home", new { ID = Model.MemoPic, Preview = true }))" />
                    </a>
                    }
                }
            </div>
        </div>
        <p>
            @Helpers.SubmitButton("保存", "btn_submit")
        </p>
    </fieldset>
}
@section Scripts{
    <style>
        #memo-editor {
            width: 99%;
            padding-left: 1px;
        }

        span.required-label {
            color: #ff0000;
        }

        .editor-label label, .editor-label span.required-label {
            height: 30px;
            font: bold 14px/30px "微软雅黑";
        }

        .editor-label {
            line-height: 2em;
            margin: 5px 0px;
            padding-left: 1em;
            background: url(/Content/images/vertical-red.png) no-repeat;
            background-color: #e3e2e2;
        }

        .editor-field {
            padding-left: 1px;
        }

        .ui-input-text {
            margin: 0px;
        }

        textarea.ui-input-text {
            width: 102%;
        }

        .field-validation-error {
            color: #f00;
            display: inline;
            margin-top: 0px;
            text-align: left;
        }
    </style>
    <script type="text/javascript">
        $(function () {
            $('#btn_submit').click(function () {
                $(this).hide();
            });
        });        
    </script>
    @if (ViewBag.Resubmit != null)
    {
    <script type="text/javascript">
        alert('请勿重复提交！');
    </script>
    }
}